<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%--
  Created by IntelliJ IDEA.
  User: LIKUS
  Date: 2019-12-11
  Time: 12:51:08
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <script src="${pageContext.request.contextPath}/js/jquery-3.4.1.js"></script>
    <title>帖子主页</title>
</head>
<body>
<center>
    <form action="${pageContext.request.contextPath}/main/list" method="post" id="myform">
        <input type="hidden" name="pageNum" id="pageNum">
        <table border="1px" width="60%" cellspacing="0" cellpadding="8" style="text-align: center">
            <tr>
                <td colspan="5"><h2>帖子列表</h2></td>
            </tr>
            <tr>
                <td colspan="5">
                    帖子标题：<input type="text" name="ctitle" value="${title}">
                    <input type="submit" value="搜索">
                </td>
            </tr>
            <tr>
                <th>标题</th>
                <th>内容摘要</th>
                <th>作者</th>
                <th>发布时间</th>
                <th>操作</th>
            </tr>
            <c:forEach items="${pageInfo.list}" var="invitation">
                <tr>
                    <td>${invitation.title}</td>
                    <td>${invitation.summary}</td>
                    <td>${invitation.author}</td>
                    <td><fmt:formatDate value="${invitation.createdate}" pattern="yyyy-MM-dd"></fmt:formatDate></td>
                     <td>
                        <a href="${pageContext.request.contextPath}/main/reply/${invitation.id}/1">查看回复</a>
                        <a href="javascript:toDel(${invitation.id})">删除</a>
                    </td>
                </tr>
            </c:forEach>
            <c:if test="${msg02 eq 'success'}">
                <tr>
                    <td colspan="5"><span style="color: brown">删除成功！</span></td>
                </tr>
            </c:if>
            <c:if test="${msg02 eq 'fail'}">
                <tr>
                    <td colspan="5"><span style="color: brown">删除失败！</span></td>
                </tr>
            </c:if>
        </table>
    </form>
    <p>
        第${pageInfo.pageNum}/${pageInfo.pages}页
        <a href="javascript:toPage(1)">首页</a>
        <a href="javascript:toPage(${pageInfo.pageNum}-1)">上一页</a>
        <a href="javascript:toPage(${pageInfo.pageNum}+1)">下一页</a>
        <a href="javascript:toPage(${pageInfo.pages})">末页</a>
    </p>
</center>
</body>
<script>
    function toPage(page) {
        $("#pageNum").val(page);
        $("#myform").submit();
    }
</script>
<script>
    function toDel(del) {
           if(window.confirm("确认删除吗？")){
               window.location.href = "${pageContext.request.contextPath}/main/remove/"+del;
           }
    }
</script>
</html>























